home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / buddy / sampdb.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1996-04-16  |  8.3 KB  |  247 lines

  1. VERSION 4.00
  2. Begin VB.Form DynamicRecordSet 
  3.    Caption         =   "DynamicRecordSet"
  4.    ClientHeight    =   7116
  5.    ClientLeft      =   876
  6.    ClientTop       =   1524
  7.    ClientWidth     =   5796
  8.    BeginProperty Font 
  9.       name            =   "Arial"
  10.       charset         =   0
  11.       weight          =   700
  12.       size            =   7.8
  13.       underline       =   0   'False
  14.       italic          =   0   'False
  15.       strikethrough   =   0   'False
  16.    EndProperty
  17.    Height          =   7440
  18.    Left            =   828
  19.    LinkTopic       =   "Form1"
  20.    ScaleHeight     =   7116
  21.    ScaleWidth      =   5796
  22.    Top             =   1248
  23.    Width           =   5892
  24.    Begin VB.CommandButton btnRecSetNamePrevious 
  25.       Caption         =   "
  26.       BeginProperty Font 
  27.          name            =   "Wingdings"
  28.          charset         =   2
  29.          weight          =   700
  30.          size            =   18
  31.          underline       =   0   'False
  32.          italic          =   0   'False
  33.          strikethrough   =   0   'False
  34.       EndProperty
  35.       Height          =   540
  36.       Left            =   1548
  37.       TabIndex        =   4
  38.       Top             =   6468
  39.       Width           =   925
  40.    End
  41.    Begin VB.CommandButton btnRecSetNameLast 
  42.       Caption         =   "
  43.       BeginProperty Font 
  44.          name            =   "Wingdings"
  45.          charset         =   2
  46.          weight          =   700
  47.          size            =   18
  48.          underline       =   0   'False
  49.          italic          =   0   'False
  50.          strikethrough   =   0   'False
  51.       EndProperty
  52.       Height          =   540
  53.       Left            =   4056
  54.       TabIndex        =   3
  55.       Top             =   6468
  56.       Width           =   925
  57.    End
  58.    Begin VB.CommandButton btnRecSetNameNext 
  59.       Caption         =   "
  60.       BeginProperty Font 
  61.          name            =   "Wingdings"
  62.          charset         =   2
  63.          weight          =   700
  64.          size            =   18
  65.          underline       =   0   'False
  66.          italic          =   0   'False
  67.          strikethrough   =   0   'False
  68.       EndProperty
  69.       Height          =   540
  70.       Left            =   2928
  71.       TabIndex        =   2
  72.       Top             =   6468
  73.       Width           =   925
  74.    End
  75.    Begin VB.CommandButton btnRecSetNameFirst 
  76.       Caption         =   "
  77.       BeginProperty Font 
  78.          name            =   "Wingdings"
  79.          charset         =   2
  80.          weight          =   700
  81.          size            =   18
  82.          underline       =   0   'False
  83.          italic          =   0   'False
  84.          strikethrough   =   0   'False
  85.       EndProperty
  86.       Height          =   540
  87.       Left            =   480
  88.       TabIndex        =   1
  89.       Top             =   6468
  90.       Width           =   925
  91.    End
  92.    Begin VB.TextBox txtName 
  93.       BeginProperty Font 
  94.          name            =   "Arial"
  95.          charset         =   0
  96.          weight          =   400
  97.          size            =   7.8
  98.          underline       =   0   'False
  99.          italic          =   0   'False
  100.          strikethrough   =   0   'False
  101.       EndProperty
  102.       Height          =   300
  103.       Index           =   0
  104.       Left            =   2232
  105.       TabIndex        =   0
  106.       Text            =   "txtName"
  107.       Top             =   408
  108.       Width           =   3396
  109.    End
  110.    Begin VB.Label lblName 
  111.       Alignment       =   1  'Right Justify
  112.       Caption         =   "lblName"
  113.       Height          =   312
  114.       Index           =   0
  115.       Left            =   84
  116.       TabIndex        =   5
  117.       Top             =   408
  118.       Width           =   2028
  119.    End
  120. Attribute VB_Name = "DynamicRecordSet"
  121. Attribute VB_Creatable = False
  122. Attribute VB_Exposed = False
  123. Public dbDatabase As Database
  124. Public rsRecSetName As Recordset
  125. Public Sub A_ReadMe()
  126. 'This template is designed for use with the RAD-Copy Buddy.
  127. 'Purpose:   This template provides Recordset navigation
  128. '           buttons along with all supporting procedures.
  129. 'Usage:     1) Change {{RecSetName}} to desired RecordSet
  130. '              variable name
  131. '           2) RAD-Copy all 4 Command Buttons and txtName
  132. '              to desired form.
  133. '           3) RAD-Copy Declarations, {{RecSetName}}ButtonStatus,
  134. '              and {{RecSetName}}Populate to desired form.
  135. '           4) On the target form, Copy/Paste txtName to create a
  136. '              ControlArray with as many Textboxes as there will be
  137. '              columns returned by your recordset.
  138. '           5) Or, RAD-Copy and call {{RecSetName}}CreateControls
  139. '              to dynamically create Labels and Textboxes for
  140. '              Recordset fields at run time.
  141. '           6) You can modify {{RecSetName}}Populate as indicated to
  142. '              bypass text box display or perform custom DB processing.
  143. '           7) Code the target form to initialize rs{{RecSetName}}
  144. '              and dbDatabase (See Sample_Form_Load).
  145. 'Comments:  These templates support fields that can be displayed
  146. '           as text only.  Template does not include routines
  147. '           for database updates.
  148. 'Tags:
  149. '{{RecSetName}}
  150. End Sub
  151. Public Sub RecSetNameCreateControls()
  152. '** Dynamically create controls and labels from the
  153. '** rsRecSetName to display fields.
  154.     Dim nColCount As Integer
  155.     Dim nTop As Integer
  156. '** Verify #of columns and initialize primary Controls
  157.     If rsRecSetName.Fields.Count > 0 Then
  158.         txtName(0).Text = ""
  159.         lblName(0).Caption = rsRecSetName.Fields(0).Name
  160.         nTop = txtName(0).Top
  161.     End If
  162. '** Loop thru remaining Fields and initialize controls
  163.     For nColCount = 1 To rsRecSetName.Fields.Count - 1
  164.         Load txtName(nColCount)
  165.         Load lblName(nColCount)
  166.         '** Calculate top independent of scale
  167.         nTop = nTop + txtName(nColCount).Height * 1.2
  168.         txtName(nColCount).Text = ""
  169.         txtName(nColCount).Top = nTop
  170.         lblName(nColCount).Caption = rsRecSetName.Fields(nColCount).Name
  171.         lblName(nColCount).Top = nTop
  172.         txtName(nColCount).Visible = True
  173.         lblName(nColCount).Visible = True
  174.     Next nColCount
  175.     Exit Sub
  176. End Sub
  177. Private Sub RecSetNameButtonStatus()
  178. '** Set Visible based on record position
  179.     If rsRecSetName.AbsolutePosition = 1 Then
  180.         btnRecSetNamePrevious.Visible = False
  181.     Else
  182.         btnRecSetNamePrevious.Visible = True
  183.     End If
  184.     If rsRecSetName.EOF Then
  185.         btnRecSetNameNext.Visible = False
  186.     Else
  187.         btnRecSetNameNext.Visible = True
  188.     End If
  189. End Sub
  190. Public Sub RecSetNamePopulate()
  191.     Dim nColCount As Integer
  192.     Dim vReturnRows As Variant
  193.     Dim vReturnValue As Variant
  194. '** Return array of current row's field values
  195.     vReturnRows = rsRecSetName.GetRows(1)
  196. '** Populate TextBoxes.  If you do not want to use the
  197. '** standard text boxes, insert your processing of the
  198. '** vReturnRows array of returned fields here:
  199.     For nColCount = 0 To rsRecSetName.Fields.Count - 1
  200.         vReturnValue = vReturnRows(nColCount, 0)
  201.         If Not IsNull(vReturnValue) Then
  202.             txtName(nColCount).Text = CStr(vReturnValue)
  203.         Else
  204.             txtName(nColCount).Text = ""
  205.         End If
  206.     Next nColCount
  207.     Exit Sub
  208. End Sub
  209. Private Sub btnRecSetNameLast_Click()
  210.     rsRecSetName.MoveLast
  211.     RecSetNamePopulate
  212.     RecSetNameButtonStatus
  213.     Exit Sub
  214. End Sub
  215. Private Sub btnRecSetNameFirst_Click()
  216.     rsRecSetName.MoveFirst
  217.     RecSetNamePopulate
  218.     RecSetNameButtonStatus
  219.     Exit Sub
  220. End Sub
  221. Private Sub btnRecSetNameNext_Click()
  222.     If Not rsRecSetName.EOF Then
  223.         RecSetNamePopulate
  224.     End If
  225.     RecSetNameButtonStatus
  226.     Exit Sub
  227. End Sub
  228. Private Sub btnRecSetNamePrevious_Click()
  229.     If Not rsRecSetName.BOF Then
  230.         rsRecSetName.MovePrevious
  231.         rsRecSetName.MovePrevious
  232.         RecSetNamePopulate
  233.     End If
  234.     RecSetNameButtonStatus
  235.     Exit Sub
  236. End Sub
  237. Private Sub Sample_Form_Load()
  238. '** Here is all initialization required prior to any
  239. '** Navigation of Recordset.
  240.     Set dbDatabase = DBEngine.Workspaces(0).OpenDatabase("c:\vb\biblio.mdb")
  241.     Set rsRecSetName = dbDatabase.OpenRecordset("select * from [publishers]")
  242.     RecSetNameCreateControls
  243.     Exit Sub
  244. End Sub
  245. Private Sub Form_Load()
  246. End Sub
  247.